<?php
class m_dropzone extends Model{
    var $table = "dropzone";
    
    function getCountRows(){
        return $this->db->count_all($this->table);
    }
    function getListDropzone($offset = NULL,$limit = NULL){
        $query = $this->db->query("select * from dropzone limit $offset,$limit");
        if($query->num_rows() > 0){
           $result = $query->result_array();    
        }else $result = array();
        
        return $result;
    }
    
    function getDropzoneById($id = NULL){
        if($id != NULL){
            $where = "where id = '$id'";
        }else $where = "";
            
        $result = array();
        $query = $this->db->query("select * from dropzone $where");
        if($query->num_rows() > 0){
           $result = $query->result_array();    
        }else $result = array();
        
        return $result;
    }
    function addDropzone($data){
        $insert = $this->db->insert($this->table,$data);
        if(!$insert){
            return FALSE;
        }else return TRUE;
    }
    function editDropzone($data){
        $this->db->where('id',$data['id']);
        $update = $this->db->update($this->table,$data);
        if(!$update){
            return FALSE;
        }else return TRUE;
    }
    function deleteDropzone($id){
        $delete = $this->db->delete($this->table,array('id'=>$id));
        if(!$delete){
            return FALSE;
        }else return TRUE;
    }
    function searchDropzone($param){
        $query = $this->db->query("select * from dropzone where locate('$param',nama) > 0 order by locate('$param',nama)");
        if($query->num_rows() > 0){
           $result = $query->result_array();    
        }else $result = array();
        
        return $result;
    }
}
?>
